/**
 * Created by jn-dinggao on 2017/7/20.
 */
app.factory('InfoUserService',  function($http, $q, $resource, $cookieStore, serviceUtil, ACTIONS, METHODS, URL){
    var factory = {};
    var param = {};


    var initParam = function(){
        param = {};
    };


    factory.addUser = function(user) {
        initParam();
        param = {};
        param.id = user.id;
        param.userId = user.userId;
        param.userName = user.userName;
        param.userEmail = user.userEmail;
        param.phoneNum = user.phoneNum;
        param.userSex = user.userSex;
        param.address = user.address;
        return serviceUtil.excute(URL.BASEURL + URL.USERURL +'add', param ,METHODS.save);
    };
    

    factory.getUserList = function(page,queryParam) {
        initParam();
        param.pageNo = page.pageNo;
        param.pageSize = page.pageSize;
        if(queryParam){
            param.userId = queryParam.userId;
            param.userName = queryParam.userName;
            param.userEmail = queryParam.userEmail;
            param.phoneNum = queryParam.phoneNum;
            param.userSex = queryParam.userSex;
        }
        return serviceUtil.excute(URL.BASEURL + URL.USERURL +'getList', param, METHODS.getList);
    };

    factory.getNoCompanyUser = function(){
        return serviceUtil.excute(URL.BASEURL + URL.USERURL +'getNoCompanyUser', param, METHODS.getList);
    };
    
    factory.get = function (id) {
        initParam();
        return serviceUtil.excute(URL.BASEURL + URL.USERURL + 'get/' + id,param,METHODS.get);
    };

    factory.logout = function () {
      return serviceUtil.excute(URL.BASEURL + URL.USERURL + 'logout',null,METHODS.get);
    };

    factory.delete = function(id){
        initParam();
        return serviceUtil.excute(URL.BASEURL + URL.USERURL+'delete/'+id,param,METHODS.delete);
    }
    return factory;
});